import fetch from 'common/src/utils/fetch'
import UTILS from "common/src/utils/utils";
 // let apiPrefix = '/dev/';
let apiPrefix = '/api/arrangementservice/';

/**
 * 教学进度分页列表
 * @param data
 */
export function findListPage(data) {
    return fetch({
        url: apiPrefix + 'teachingProgress/page',
        method: 'post',
        data: data
    });
}

/**
 * 审核列表
 * @param data
 */
export function findAuditPage(data) {
    return fetch({
        url: apiPrefix + 'teachingProgress/auditPage',
        method: 'post',
        data: data
    });
}

/**
 * 控制指定审核人按钮显示
 */
export function canAuditOption(deptId,teachingClassId) {
  return fetch({
      url: apiPrefix + 'teachingProgress/canAuditOption?deptId='+deptId+"&teachingClassId="+teachingClassId,
      method: 'get'
  });
}

/**
 * 指定审核人
 * @param data
 */
export function assign(data) {
  return fetch({
      url: apiPrefix + 'teachingProgress/assign',
      method: 'post',
      data: data
  });
}

/**
 * 教学进度查询
 * @param data
 */
export function progressQuery(data) {
    return fetch({
        url: apiPrefix + 'teachingProgress/progressQuery',
        method: 'post',
        data: data
    });
}

/**
 * 复制时筛选自己任课、已经填写的数据
 * @param data
 */
export function findOwner(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/findOwner',
    method: 'post',
    data: data
  });
}

/**
 * 查询
 * @param data
 */
export function getDetailById(id) {
  return fetch({
    url:apiPrefix + 'teachingProgress/getTeachingProgressById?id='+id,
    method: 'get'
  })
}
/**
 *分页查询填写状态
 * @param data
 */
export function showWriteStatus(data) {
  return fetch({
    url: apiPrefix +'teachingProgress/showWriteStatus',
    method: 'post',
    data:data
  });
}
/**
 *根据rowId删除行
 * @param id
 */
export function deleteByContentRowId(id,teachingClassId) {
  return fetch({
    url:apiPrefix + 'teachingProgress/deleteByContentRowId?id='+id+"&teachingClassId="+teachingClassId,
    method: 'get'
  })
}

/**
 * 分页详情post
 * @param data
 */
export function getPageContentById(data) {
  return fetch({
    url:apiPrefix + 'teachingProgress/getPageContentById',
    method: 'post',
    data:data
  })
}

/**
 * 不分页详情get
 * @param id
 */
export function getContentById(id) {
  return fetch({
    url:apiPrefix + 'teachingProgress/getContentById?id='+id,
    method: 'get'
  })
}
/**
 * 导出pdf功能页面数据
 */
export function getExportPdfData(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/getContentByIds?ids='+data,
    method: 'get'
  });
}
// export function getExportPdfData(data) {
//   return fetch({
//     url: apiPrefix + 'teachingProgress/getContentByIds?ids='+data,
//     method: 'get'
//   });
// }
/**
 * 导出pdf功能页面数据
 */
export function showAdjustStatics(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/showAdjustStatics',
    method: 'post',
    data:data
  });
}
/**
 * 导出调课统计
 */
export function exportExChange(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportExChange',
    method: 'post',
    data: data
  });
}

/**
 * 导出教学进度详细信息
 */
export function exportDetail(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportDetail',
    method: 'post',
    data: data
  });
}

/**
 *导出pdf
 * @param data
 */
export function exportDetailPdf(id,term) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportDetailPdf?id='+id+'&term='+term,
    method: 'get',
  });
}

/**
 * 导出教学进度填写状态
 */
export function exportWriteStatus(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportWriteStatus',
    method: 'post',
    data: data
  });
}
/**
 * 导出不合格
 */
export function exportEligible(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportEligible',
    method: 'post',
    data: data
  });
}
/**
 * 导出上课内容excel
 * @param data
 */
export function exportClassContent(teachingClassId,courseId) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportClassContent?teachingClassId='+teachingClassId+'&courseId='+courseId,
    method: 'get',
  });
}

/**
 * 审核
 * @param data
 */
export function auditProgress(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/auditProgress',
    method: 'post',
    data: data
  });
}

/**
 * 撤回审核
 * @param data
 */
export function reverseAudit(id) {
  return fetch({
    url: apiPrefix + '/teachingProgress/reverseAudit?id='+id,
    method: 'get',
  });
}

  /**
   * 更新(显示、隐藏)
   * @param data
   */
export function updateTeachingProgress(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/updateTeachingProgress',
    method: 'post',
    data: data
  });
}

/**
 *复制功能
 * @param data
 */
export function copyContent(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/copyContent',
    method: 'post',
    data: data
  });
}

/**
 * 暂存(更新上课内容)
 * @param data
 */
export function updateContent(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/updateContent',
    method: 'post',
    data: data
  });
}

/**
 * 导出列表
 * @param data
 */
export function exportList(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportList',
    method: 'post',
    data: data
  });
}

/**
 * 异步导出
 * @param data
 */
export function exportList2(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/exportList2',
    method: 'post',
    data: data
  });
}

/**
 * 异步导出 zip包
 */
export function batchPrint(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/batchPrint',
    method: 'post',
    responseType: 'blob',
    data: data
  }).then(res => {
    UTILS.downloadFile(res, 'Result.zip', 'application/zip;charset=utf-8');
  });
}

export function getReportStatus(key) {
  return fetch({
    url: apiPrefix + 'teachingProgress/result/' + key,
    method: 'get'
  });
}

/**
 *提交审核
 * @param data
 */
export function checkProgress(data) {
  return fetch({
    url: apiPrefix + 'teachingProgress/checkProgress',
    method: 'post',
    data: data
  });
}

/**
 * 授课老师，助教信息回显
 */
export function getAssistTeacher(teachingClassId) {
  return fetch({
    url: apiPrefix + 'teachingProgress/getAssistTeacher?teachingClassId=' + teachingClassId,
    method: 'get'
  });
}

  /**
   *批量修改进度表录入状态
   */
export function updateInputFlag(data) {
  return fetch({
    url:apiPrefix + 'teachingProgress/updateInputFlag',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: data
  })
}

/**
 * 导出教学进度pdf
 * 多页合并一页
 */
export function exportDetailPdf2(data) { 
  return fetch({
    url:apiPrefix + '/teachingProgress/exportDetailPdf2',
    method: 'post',
    data:data
  })
}

/**
 * 授课老师下拉框数据list
 */
 export function findTeacherOptions(teachingClassId) {
  return fetch({
    url: apiPrefix + 'teachingProgress/findTeacherOptions?teachingClassId=' + teachingClassId,
    method: 'get'
  });
}
/**
 * 判断登录人是否事教务院长
 */
export function checkHasAuthority() {
  return fetch({
    url: apiPrefix + 'teachingProgress/checkHasAuthority',
    method: 'get'
  });
}

export default {
  findListPage,
  findAuditPage,
  assign,
  canAuditOption,
  progressQuery,
  findOwner,
  exportList,
  exportList2,
  exportExChange,
  exportDetail,
  exportDetailPdf,
  exportWriteStatus,
  exportClassContent,
  auditProgress,
  reverseAudit,
  updateTeachingProgress,
  updateContent,
  getAssistTeacher,
  updateInputFlag,
  checkProgress,
  copyContent,
  getDetailById,
  deleteByContentRowId,
  getContentById,
  getPageContentById,
  exportEligible,
  getExportPdfData,
  showWriteStatus,
  showAdjustStatics,
  exportDetailPdf2,
  findTeacherOptions,
  batchPrint,
  checkHasAuthority,
}

